﻿using Bussiness.DEV;
using HNCAPI_INTERFACE;
using Model;
using System;
using System.Collections.Generic;
using System.Threading;

namespace Bussiness
{
    public class HNC : IDEV
    {
        public Device Device { get; set; }
        public List<DevicePOI> DevicePOIList { get; set; }
        private HncApi HncApi;
        private bool ConnectSucc;

        public Result Connect()
        {
            Result result = new Result();
            ConnectSucc = false;
            HncApi = new HncApi();
            Int16 ret = HncApi.HNC_NetConnect(Device.IP, (ushort)Device.Port, OnConnect);
            if (ret != 0)
            {
                result.Msg = "";
                return result;
            }

            HncApi.HNC_AlarmSubscribe(false);
            HncApi.HNC_EventSubscribe(false);
            HncApi.HNC_ClientRequestWriteToken();
            Thread.Sleep(3000);
            result.Success = ConnectSucc;
            result.Msg = ConnectSucc ? "连接成功" : "连接失败";
            return result;
        }

        private void OnConnect(string ip, ushort port, bool result)
        {
            if (result)
            {
                ConnectSucc = true;
            }
        }

        public Result<List<Cfg_Field>> Read()
        {
            Result<List<Cfg_Field>> result = new Result<List<Cfg_Field>>();
            foreach (var devicePOI in DevicePOIList)
            {
                Cfg_Field cfg_Field = new Cfg_Field();
                cfg_Field.name = devicePOI.DevPOIAlias;
                int axisType = 0;
                switch (devicePOI.DevPOIName)
                {
                    case "轴类型":
                        axisType = (int)HncAxis.HNC_AXIS_TYPE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道号":
                        axisType = (int)HncAxis.HNC_AXIS_CHAN;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道中的轴号":
                        axisType = (int)HncAxis.HNC_AXIS_CHAN_INDEX;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道中的主轴号":
                        axisType = (int)HncAxis.HNC_AXIS_CHAN_SINDEX;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "引导轴":
                        axisType = (int)HncAxis.HNC_AXIS_LEAD;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "机床实际位置":
                        axisType = (int)HncAxis.HNC_AXIS_ACT_POS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "机床实际位置2":
                        axisType = (int)HncAxis.HNC_AXIS_ACT_POS2;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "机床指令位置":
                        axisType = (int)HncAxis.HNC_AXIS_CMD_POS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "工件实际位置":
                        axisType = (int)HncAxis.HNC_AXIS_ACT_POS_WCS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "工件指令位置":
                        axisType = (int)HncAxis.HNC_AXIS_CMD_POS_WCS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "相对实际位置":
                        axisType = (int)HncAxis.HNC_AXIS_ACT_POS_RCS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "相对指令位置":
                        axisType = (int)HncAxis.HNC_AXIS_CMD_POS_RCS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "实际脉冲位置":
                        axisType = (int)HncAxis.HNC_AXIS_ACT_PULSE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "指令脉冲位置":
                        axisType = (int)HncAxis.HNC_AXIS_CMD_PULSE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "编程位置":
                        axisType = (int)HncAxis.HNC_AXIS_PROG_POS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "电机位置":
                        axisType = (int)HncAxis.HNC_AXIS_ENC_CNTR;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "指令速度":
                        axisType = (int)HncAxis.HNC_AXIS_CMD_VEL;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "剩余进给":
                        axisType = (int)HncAxis.HNC_AXIS_LEFT_TOGO;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "工件零点":
                        axisType = (int)HncAxis.HNC_AXIS_WCS_ZERO;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "手轮中断偏移量":
                        axisType = (int)HncAxis.HNC_AXIS_WHEEl_OFF;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "跟踪误差":
                        axisType = (int)HncAxis.HNC_AXIS_FOLLOW_ERR;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "同步误差":
                        axisType = (int)HncAxis.HNC_AXIS_SYN_ERR;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "轴补偿值":
                        axisType = (int)HncAxis.HNC_AXIS_COMP;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "Z脉冲偏移":
                        axisType = (int)HncAxis.HNC_AXIS_ZSW_DIST;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "相对零点":
                        axisType = (int)HncAxis.HNC_AXIS_REAL_ZERO;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "回零完成":
                        axisType = (int)HncAxis.HNC_AXIS_IS_HOMEF;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "伺服类型出错标志":
                        axisType = (int)HncAxis.HNC_AXIS_MOTOR_TYPE_FLAG;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "实际速度":
                        axisType = (int)HncAxis.HNC_AXIS_ACT_VEL;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "电机转速":
                        axisType = (int)HncAxis.HNC_AXIS_MOTOR_REV;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "驱动单元电流":
                        axisType = (int)HncAxis.HNC_AXIS_DRIVE_CUR;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "负载电流":
                        axisType = (int)HncAxis.HNC_AXIS_LOAD_CUR;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "额定电流":
                        axisType = (int)HncAxis.HNC_AXIS_RATED_CUR;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "波形频率":
                        axisType = (int)HncAxis.HNC_AXIS_WAVE_FREQ;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "轴名":
                        axisType = (int)HncAxis.HNC_AXIS_NAME;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "伺服驱动版本":
                        axisType = (int)HncAxis.HNC_AXIS_DRIVE_VER;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "伺服类型":
                        axisType = (int)HncAxis.HNC_AXIS_MOTOR_TYPE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                }

                if (axisType > 0)
                {
                    string strValue = string.Empty;
                    int intValue = 0;
                    double doubleValue = 0;
                    string value = string.Empty;
                    int ret;

                    switch (devicePOI.DevPOIType)
                    {
                        case (int)DevPOIType.data_int:
                            ret = HncApi.HNC_AxisGetValue(axisType, 0, ref intValue);
                            if (ret == 0)
                            {
                                value = intValue.ToString();
                            }
                            break;
                        case (int)DevPOIType.data_float:
                            ret = HncApi.HNC_AxisGetValue(axisType, 0, ref doubleValue);
                            if (ret == 0)
                            {
                                result.Success = true;
                                value = doubleValue.ToString();
                            }
                            break;
                        case (int)DevPOIType.data_string:
                            ret = HncApi.HNC_AxisGetValue(axisType, 0, ref strValue);
                            if (ret == 0)
                            {
                                result.Success = true;
                                value = strValue;
                            }
                            break;
                    }

                    cfg_Field.value = value;
                    result.Data.Add(cfg_Field);
                }

                int chanType = 0;
                switch (devicePOI.DevPOIName)
                {
                    case "通道是否存在":
                        chanType = (int)HncChannel.HNC_CHAN_IS_EXIST;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道的机床类型":
                        chanType = (int)HncChannel.HNC_CHAN_MAC_TYPE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "轴掩码":
                        chanType = (int)HncChannel.HNC_CHAN_AXES_MASK;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "轴掩码1":
                        chanType = (int)HncChannel.HNC_CHAN_AXES_MASK1;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道名":
                        chanType = (int)HncChannel.HNC_CHAN_NAME;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "读取当前G代码的标志":
                        chanType = (int)HncChannel.HNC_CHAN_CMD_TYPE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "指令进给速度":
                        chanType = (int)HncChannel.HNC_CHAN_CMD_FEEDRATE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "实际进给速度":
                        chanType = (int)HncChannel.HNC_CHAN_ACT_FEEDRATE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "编程指令速度":
                        chanType = (int)HncChannel.HNC_CHAN_PROG_FEEDRATE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "进给修调":
                        chanType = (int)HncChannel.HNC_CHAN_FEED_OVERRIDE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "快移修调":
                        chanType = (int)HncChannel.HNC_CHAN_RAPID_OVERRIDE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道的M指令":
                        chanType = (int)HncChannel.HNC_CHAN_MCODE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道的T指令":
                        chanType = (int)HncChannel.HNC_CHAN_TCODE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道中的刀偏号":
                        chanType = (int)HncChannel.HNC_CHAN_TOFFS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "当前刀具":
                        chanType = (int)HncChannel.HNC_CHAN_TOOL_USE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "准备好交换的刀具":
                        chanType = (int)HncChannel.HNC_CHAN_TOOL_RDY;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "模式":
                        chanType = (int)HncChannel.HNC_CHAN_MODE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "MDI":
                        chanType = (int)HncChannel.HNC_CHAN_IS_MDI;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "循环启动":
                        chanType = (int)HncChannel.HNC_CHAN_CYCLE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "进给保持":
                        chanType = (int)HncChannel.HNC_CHAN_HOLD;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "已选程序":
                        chanType = (int)HncChannel.HNC_CHAN_IS_PROGSEL;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "程序运行完成":
                        chanType = (int)HncChannel.HNC_CHAN_IS_PROGEND;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "螺纹加工":
                        chanType = (int)HncChannel.HNC_CHAN_IS_THREADING;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "刚性攻丝":
                        chanType = (int)HncChannel.HNC_CHAN_IS_RIGID;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "重运行复位状态":
                        chanType = (int)HncChannel.HNC_CHAN_IS_REWINDED;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "急停":
                        chanType = (int)HncChannel.HNC_CHAN_IS_ESTOP;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "复位":
                        chanType = (int)HncChannel.HNC_CHAN_IS_RESETTING;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "运行中":
                        chanType = (int)HncChannel.HNC_CHAN_IS_RUNNING;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "回零中":
                        chanType = (int)HncChannel.HNC_CHAN_IS_HOMING;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "轴移动中":
                        chanType = (int)HncChannel.HNC_CHAN_IS_MOVING;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "直半径编程":
                        chanType = (int)HncChannel.HNC_CHAN_DIAMETER;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "校验":
                        chanType = (int)HncChannel.HNC_CHAN_VERIFY;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "运行行":
                        chanType = (int)HncChannel.HNC_CHAN_RUN_ROW;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "译码行":
                        chanType = (int)HncChannel.HNC_CHAN_DCD_ROW;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "选择程序的编号":
                        chanType = (int)HncChannel.HNC_CHAN_SEL_PROG;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "运行程序的编号":
                        chanType = (int)HncChannel.HNC_CHAN_RUN_PROG;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "加工计数":
                        chanType = (int)HncChannel.HNC_CHAN_PART_CNTR;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "工件总数":
                        chanType = (int)HncChannel.HNC_CHAN_PART_STATI;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道轴对应的逻辑轴号":
                        chanType = (int)HncChannel.HNC_CHAN_LAX;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "编程轴名":
                        chanType = (int)HncChannel.HNC_CHAN_AXIS_NAME;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "编程主轴名":
                        chanType = (int)HncChannel.HNC_CHAN_SPDL_NAME;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "通道模态":
                        chanType = (int)HncChannel.HNC_CHAN_MODAL;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道主轴对应的逻辑轴号，动态":
                        chanType = (int)HncChannel.HNC_CHAN_SPDL_LAX;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "通道主轴对应的逻辑轴号，静态":
                        chanType = (int)HncChannel.HNC_CHAN_SPDL_PARA_LAX;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "主轴指令速度":
                        chanType = (int)HncChannel.HNC_CHAN_CMD_SPDL_SPEED;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "主轴实际速度":
                        chanType = (int)HncChannel.HNC_CHAN_ACT_SPDL_SPEED;
                        devicePOI.DevPOIType = (int)DevPOIType.data_float;
                        break;
                    case "主轴修调":
                        chanType = (int)HncChannel.HNC_CHAN_SPDL_OVERRIDE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "断点位置":
                        chanType = (int)HncChannel.HNC_CHAN_BP_POS;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "正在调用手动子程序":
                        chanType = (int)HncChannel.HNC_CHAN_PROG_FLOW;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "当前使用刀具长度补偿号":
                        chanType = (int)HncChannel.HNC_CHAN_H_OFF;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "当前使用刀具半径补偿号":
                        chanType = (int)HncChannel.HNC_CHAN_D_OFF;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                }

                if (chanType > 0)
                {
                    string strValue = string.Empty;
                    int intValue = 0;
                    double doubleValue = 0;
                    string value = string.Empty;
                    int ret;

                    switch (devicePOI.DevPOIType)
                    {
                        case (int)DevPOIType.data_int:
                            ret = HncApi.HNC_ChannelGetValue(chanType, 0,0, ref intValue);
                            if (ret == 0)
                            {
                                value = intValue.ToString();
                            }
                            break;
                        case (int)DevPOIType.data_float:
                            ret = HncApi.HNC_ChannelGetValue(chanType,0, 0, ref doubleValue);
                            if (ret == 0)
                            {
                                result.Success = true;
                                value = doubleValue.ToString();
                            }
                            break;
                        case (int)DevPOIType.data_string:
                            ret = HncApi.HNC_ChannelGetValue(chanType,0, 0, ref strValue);
                            if (ret == 0)
                            {
                                result.Success = true;
                                value = strValue;
                            }
                            break;
                    }

                    cfg_Field.value = value;
                    result.Data.Add(cfg_Field);
                }

                int sysType = 0;
                switch (devicePOI.DevPOIName)
                {
                    case "获取系统通道数":
                        sysType = (int)HncSystem.HNC_SYS_CHAN_NUM;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "长度分辨率":
                        sysType = (int)HncSystem.HNC_SYS_MOVE_UNIT;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "角度分辨率":
                        sysType = (int)HncSystem.HNC_SYS_TURN_UNIT;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "公英制":
                        sysType = (int)HncSystem.HNC_SYS_METRIC_DISP;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "显示时间":
                        sysType = (int)HncSystem.HNC_SYS_SHOW_TIME;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "报警自动显示":
                        sysType = (int)HncSystem.HNC_SYS_POP_ALARM;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "图形自动擦除":
                        sysType = (int)HncSystem.HNC_SYS_GRAPH_ERASE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "机床类型":
                        sysType = (int)HncSystem.HNC_SYS_MAC_TYPE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "坐标系精度":
                        sysType = (int)HncSystem.HNC_SYS_PREC;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "F精度":
                        sysType = (int)HncSystem.HNC_SYS_F_PREC;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "S精度":
                        sysType = (int)HncSystem.HNC_SYS_S_PREC;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "NCK版本":
                        sysType = (int)HncSystem.HNC_SYS_NCK_VER;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "DRV版本":
                        sysType = (int)HncSystem.HNC_SYS_DRV_VER;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "PLC版本":
                        sysType = (int)HncSystem.HNC_SYS_PLC_VER;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "CNC版本":
                        sysType = (int)HncSystem.HNC_SYS_CNC_VER;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "MCP面板钥匙开关":
                        sysType = (int)HncSystem.HNC_SYS_MCP_KEY;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "活动通道":
                        sysType = (int)HncSystem.HNC_SYS_ACTIVE_CHAN;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "请求通道":
                        sysType = (int)HncSystem.HNC_SYS_REQUEST_CHAN;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "MDI运行通道":
                        sysType = (int)HncSystem.HNC_SYS_MDI_CHAN;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "请求的通道屏蔽字":
                        sysType = (int)HncSystem.HNC_SYS_REQUEST_CHAN_MASK;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "进给保持后是否重新解释":
                        sysType = (int)HncSystem.HNC_SYS_IS_HOLD_REDECODE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "NC版本":
                        sysType = (int)HncSystem.HNC_SYS_NC_VER;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "CF卡SN号":
                        sysType = (int)HncSystem.HNC_SYS_SN_NUM;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "机床型号":
                        sysType = (int)HncSystem.HNC_SYS_MACHINE_TYPE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "机床信息":
                        sysType = (int)HncSystem.HNC_SYS_MACHINE_INFO;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "机床厂信息":
                        sysType = (int)HncSystem.HNC_SYS_MACFAC_INFO;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "用户信息":
                        sysType = (int)HncSystem.HNC_SYS_USER_INFO;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "机床编号":
                        sysType = (int)HncSystem.HNC_SYS_MACHINE_NUM;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "出厂时间":
                        sysType = (int)HncSystem.HNC_SYS_EXFACTORY_DATE;
                        devicePOI.DevPOIType = (int)DevPOIType.data_string;
                        break;
                    case "权限等级":
                        sysType = (int)HncSystem.HNC_SYS_ACCESS_LEVEL;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "权限钥匙锁":
                        sysType = (int)HncSystem.HNC_SYS_RIGHTS_KEY;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                    case "注册剩余天数":
                        sysType = (int)HncSystem.HNC_SYS_REG_DAYS_REMANING;
                        devicePOI.DevPOIType = (int)DevPOIType.data_int;
                        break;
                }

                if (sysType > 0)
                {
                    string strValue = string.Empty;
                    int intValue = 0;
                    string value = string.Empty;
                    int ret;

                    switch (devicePOI.DevPOIType)
                    {
                        case (int)DevPOIType.data_int:
                            ret = HncApi.HNC_SystemGetValue(sysType,ref intValue);
                            if (ret == 0)
                            {
                                result.Success = true;
                                value = intValue.ToString();
                            }
                            break;
                        case (int)DevPOIType.data_string:
                            ret = HncApi.HNC_SystemGetValue(sysType,ref strValue);
                            if (ret == 0)
                            {
                                result.Success = true;
                                value = strValue;
                            }
                            break;
                    }

                    cfg_Field.value = value;
                    result.Data.Add(cfg_Field);
                }
            }
            
            return result;
        }
    }
}
